class CreateSerialSubjects < ActiveRecord::Migration
  def self.up
    create_table :serial_subjects do |t|
      t.references :subject
      t.integer :requisite_id
      t.boolean :is_serialization_required
      t.integer :ordering

      t.timestamps
    end
    add_index(:serial_subjects, [:subject_id, :requisite_id], :unique => true)
    add_index(:serial_subjects, :subject_id, :unique => false)
  end

  def self.down
    remove_index(:serial_subjects, :column => [:subject_id, :requisite_id])
    remove_index(:serial_subjects, :column => :subject_id)
    drop_table :serial_subjects
  end
end
